package com.hucc.api.domain.res;

import lombok.Data;

/**
 * @author huguocai
 */
@Data
public class ApiResult<T> {
    int code = 200;

    T data;

    String message;

    public ApiResult(int code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public static <T> ApiResult<T> success(T data) {
        return new ApiResult<T>(200, data, null);
    }

    public static <T> ApiResult<T> success() {
        return new ApiResult<T>(200, null, null);
    }

    public static <T> ApiResult<T> fail(String message) {
        return new ApiResult<T>(500, null, message);
    }
}
